package com.datastructure.test.reverseword;

public class ReverseWord {

    public static void main(String[] args) {
        ReverseWord reverseWord = new ReverseWord();
        String word = reverseWord.reverseWord("nowcoder");
        System.out.println(word);
    }

    public String reverseWord (String str) {
        // write code here
        if(str==null||str.length()==1){
            return str;
        }
        String[] split = str.split(" ");
        StringBuilder stringBuilder;
        for (int i = 0; i < split.length; i++) {
            stringBuilder=new StringBuilder(split[i]);
            split[i]=stringBuilder.reverse().toString();
        }
       return String.join(" ",split);
    }

    public int cuberoot (int n) {
        // write code here
        double ceil = Math.floor(Math.pow(n, 1/3.0));
        return (int) ceil;
    }
}
